<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="google-site-verification" content="xBT4GhYoi5qRD5tr338pgPM5OWHHIDR6mNg1a3euekI" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="keyword"  content="Tooi">
    <link rel="shortcut icon" href="/img/favicon.ico">

    <title>
        
        使用 Nexus 搭建 Maven 私服 - Tooi的博客 | Tooi-Blog
        
    </title>

    <!-- Custom CSS -->
    <link rel="stylesheet" href="/css/aircloud.css">
    <link rel="stylesheet" href="/css/gitment.css">
    <!--<link rel="stylesheet" href="https://imsun.github.io/gitment/style/default.css">-->
    <link href="//at.alicdn.com/t/font_620856_pl6z7sid89qkt9.css" rel="stylesheet" type="text/css">
    <!-- ga & ba script hoook -->
    <script></script>
</head>

<body>

<div class="site-nav-toggle" id="site-nav-toggle">
    <button>
        <span class="btn-bar"></span>
        <span class="btn-bar"></span>
        <span class="btn-bar"></span>
    </button>
</div>

<div class="index-about">
    <i> 瞄准月亮。 </i>
</div>

<div class="index-container">
    
    <div class="index-left">
        
<div class="nav" id="nav">
    <div class="avatar-name">
        <div class="avatar ">
            <img src="/img/avatar.jpg" />
        </div>
        <div class="name">
            <i>Tooi6</i>
        </div>
    </div>
    <div class="contents" id="nav-content">
        <ul>
            <li >
                <a href="/">
                    <i class="iconfont icon-shouye1"></i>
                    <span>主页</span>
                </a>
            </li>
            <li >
                <a href="/tags">
                    <i class="iconfont icon-biaoqian1"></i>
                    <span>标签</span>
                </a>
            </li>
            <li >
                <a href="/archives">
                    <i class="iconfont icon-guidang2"></i>
                    <span>存档</span>
                </a>
            </li>
            <li >
                <a href="/about/">
                    <i class="iconfont icon-guanyu2"></i>
                    <span>关于</span>
                </a>
            </li>
            
            <li>
                <a id="search">
                    <i class="iconfont icon-sousuo1"></i>
                    <span>搜索</span>
                </a>
            </li>
            
        </ul>
    </div>
    
        <div id="toc" class="toc-article">
    <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#简介"><span class="toc-text">简介</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#部署-Nexus"><span class="toc-text">部署 Nexus</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#部署环境"><span class="toc-text">部署环境</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#开始部署"><span class="toc-text">开始部署</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#开始使用"><span class="toc-text">开始使用</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#配置认证信息"><span class="toc-text">配置认证信息</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#配置自动化部署"><span class="toc-text">配置自动化部署</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#上传第三方-JAR-包"><span class="toc-text">上传第三方 JAR 包</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#配置代理仓库"><span class="toc-text">配置代理仓库</span></a></li></ol></li></ol>
</div>
    
</div>


<div class="search-field" id="search-field">
    <div class="search-container">
        <div class="search-input">
            <span id="esc-search"> <i class="icon-fanhui iconfont"></i></span>
            <input id="search-input"/>
            <span id="begin-search">搜索</span>
        </div>
        <div class="search-result-container" id="search-result-container">

        </div>
    </div>
</div>

        <div class="index-about-mobile">
            <i> 瞄准月亮。 </i>
        </div>
    </div>
    
    <div class="index-middle">
        <!-- Main Content -->
        


<div class="post-container">
    <div class="post-title">
        使用 Nexus 搭建 Maven 私服
    </div>

    <div class="post-meta">
        <span class="attr">发布于：<span>2019-11-06 18:04:15</span></span>
        
        <span class="attr">标签：/
        
        <a class="tag" href="/tags/#Docker" title="Docker">Docker</a>
        <span>/</span>
        
        <a class="tag" href="/tags/#Nexus" title="Nexus">Nexus</a>
        <span>/</span>
        
        <a class="tag" href="/tags/#Maven" title="Maven">Maven</a>
        <span>/</span>
        
        
        </span>
        <span class="attr">访问：<span id="busuanzi_value_page_pv"></span>
</span>
</span>
    </div>
    <div class="post-content ">
        <h3 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h3><blockquote>
<p>Nexus 是一个强大的<strong>仓库管理器</strong>，极大地简化了内部仓库的维护和外部仓库的访问。    </p>
</blockquote>
<h3 id="部署-Nexus"><a href="#部署-Nexus" class="headerlink" title="部署 Nexus"></a>部署 Nexus</h3><h4 id="部署环境"><a href="#部署环境" class="headerlink" title="部署环境"></a>部署环境</h4><table>
<thead>
<tr>
<th>操作系统</th>
<th>Ubuntu Server 16.04 LTS</th>
</tr>
</thead>
<tbody><tr>
<td>cpu</td>
<td>2核</td>
</tr>
<tr>
<td>内存</td>
<td>G</td>
</tr>
</tbody></table>
<h4 id="开始部署"><a href="#开始部署" class="headerlink" title="开始部署"></a>开始部署</h4><blockquote>
<p>Docker 镜像：<a href="https://hub.docker.com/r/sonatype/nexus3" target="_blank" rel="noopener">https://hub.docker.com/r/sonatype/nexus3</a>  </p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"># 拉取镜像  </span><br><span class="line">docker pull sonatype/nexus3  </span><br><span class="line"></span><br><span class="line">### docker-compose.yml  </span><br><span class="line">version: &apos;3.1&apos;</span><br><span class="line">services:</span><br><span class="line">  nexus:</span><br><span class="line">    restart: always</span><br><span class="line">    image: sonatype/nexus3</span><br><span class="line">    container_name: nexus</span><br><span class="line">    ports:</span><br><span class="line">      - 8081:8081</span><br><span class="line">    volumes:</span><br><span class="line">      - /usr/local/docker/nexus/data:/nexus-data</span><br><span class="line">###</span><br></pre></td></tr></table></figure>

<h3 id="开始使用"><a href="#开始使用" class="headerlink" title="开始使用"></a>开始使用</h3><blockquote>
<p>服务启动后第一次登陆需要输入密码，初始密码在服务器文件 nexus/data/admin.password 中。  </p>
</blockquote>
<h4 id="配置认证信息"><a href="#配置认证信息" class="headerlink" title="配置认证信息"></a>配置认证信息</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"># 在maven配置文件中添加   </span><br><span class="line">&lt;server&gt;</span><br><span class="line">  &lt;id&gt;nexus-releases&lt;/id&gt;</span><br><span class="line">  &lt;username&gt;admin&lt;/username&gt;</span><br><span class="line">  &lt;password&gt;adminpassowrd&lt;/password&gt;</span><br><span class="line">&lt;/server&gt;</span><br><span class="line"></span><br><span class="line">&lt;server&gt;</span><br><span class="line">  &lt;id&gt;nexus-snapshots&lt;/id&gt;</span><br><span class="line">  &lt;username&gt;admin&lt;/username&gt;</span><br><span class="line">  &lt;password&gt;adminpassowrd&lt;/password&gt;</span><br><span class="line">&lt;/server&gt;</span><br></pre></td></tr></table></figure>

<h4 id="配置自动化部署"><a href="#配置自动化部署" class="headerlink" title="配置自动化部署"></a>配置自动化部署</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"># 项目的pom中添加</span><br><span class="line">&lt;distributionManagement&gt;  </span><br><span class="line">  &lt;repository&gt;  </span><br><span class="line">    &lt;id&gt;nexus-releases&lt;/id&gt;  </span><br><span class="line">    &lt;name&gt;Nexus Release Repository&lt;/name&gt;  </span><br><span class="line">    &lt;url&gt;http://192.168.213.128:8081/repository/maven-releases/&lt;/url&gt;  </span><br><span class="line">  &lt;/repository&gt;  </span><br><span class="line">  &lt;snapshotRepository&gt;  </span><br><span class="line">    &lt;id&gt;nexus-snapshots&lt;/id&gt;  </span><br><span class="line">    &lt;name&gt;Nexus Snapshot Repository&lt;/name&gt;  </span><br><span class="line">    &lt;url&gt;http://192.168.213.128:8081/repository/maven-snapshots/&lt;/url&gt;  </span><br><span class="line">  &lt;/snapshotRepository&gt;  </span><br><span class="line">&lt;/distributionManagement&gt;</span><br></pre></td></tr></table></figure>


<h4 id="上传第三方-JAR-包"><a href="#上传第三方-JAR-包" class="headerlink" title="上传第三方 JAR 包"></a>上传第三方 JAR 包</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"># 如第三方JAR包：kaptcha-2.3.0.jar</span><br><span class="line">mvn deploy:deploy-file </span><br><span class="line">  -DgroupId=com.google.code.kaptcha </span><br><span class="line">  -DartifactId=kaptcha</span><br><span class="line">  -Dversion=2.3.0 </span><br><span class="line">  -Dpackaging=jar </span><br><span class="line">  -Dfile=D:\codes\kaptcha-2.3.0.jar </span><br><span class="line">  -Durl=http://192.168.213.128:8081/repository/maven-releases/</span><br><span class="line">  -DrepositoryId=nexus-releases</span><br></pre></td></tr></table></figure>

<h4 id="配置代理仓库"><a href="#配置代理仓库" class="headerlink" title="配置代理仓库"></a>配置代理仓库</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">&lt;repositories&gt;</span><br><span class="line">    &lt;repository&gt;</span><br><span class="line">        &lt;id&gt;nexus-releases&lt;/id&gt;</span><br><span class="line">        &lt;name&gt;Nexus Repository&lt;/name&gt;</span><br><span class="line">        &lt;url&gt;http://192.168.213.128:8081/repository/maven-public/&lt;/url&gt;</span><br><span class="line">        &lt;snapshots&gt;</span><br><span class="line">            &lt;enabled&gt;true&lt;/enabled&gt;</span><br><span class="line">        &lt;/snapshots&gt;</span><br><span class="line">        &lt;releases&gt;</span><br><span class="line">            &lt;enabled&gt;true&lt;/enabled&gt;</span><br><span class="line">        &lt;/releases&gt;</span><br><span class="line">    &lt;/repository&gt;</span><br><span class="line">&lt;/repositories&gt;</span><br><span class="line">&lt;pluginRepositories&gt;</span><br><span class="line">    &lt;pluginRepository&gt;</span><br><span class="line">        &lt;id&gt;nexus-releases&lt;/id&gt;</span><br><span class="line">        &lt;name&gt;Nexus Plugin Repository&lt;/name&gt;</span><br><span class="line">        &lt;url&gt;http://192.168.213.128:8081/repository/maven-public/&lt;/url&gt;</span><br><span class="line">        &lt;snapshots&gt;</span><br><span class="line">            &lt;enabled&gt;true&lt;/enabled&gt;</span><br><span class="line">        &lt;/snapshots&gt;</span><br><span class="line">        &lt;releases&gt;</span><br><span class="line">            &lt;enabled&gt;true&lt;/enabled&gt;</span><br><span class="line">        &lt;/releases&gt;</span><br><span class="line">    &lt;/pluginRepository&gt;</span><br><span class="line">&lt;/pluginRepositories&gt;</span><br></pre></td></tr></table></figure>

        
            <div class="donate-container">
    <div class="donate-button">
        <button id="donate-button">赞赏</button>
    </div>
    <div class="donate-img-container hide" id="donate-img-container">
        <img id="donate-img" src="" data-src="/img/donate.png">
        <p> 感谢鼓励 </p>
    </div>
</div>
        
        <br />
        <div id="comment-container">
        </div>
        <div id="disqus_thread"></div>

        <div id="lv-container">
        </div>

    </div>
</div>

    </div>
</div>


<footer class="footer">
    <ul class="list-inline text-center">
        
        

        

        

        
        <li>
            <a target="_blank"  href="https://github.com/Tooi6">
                            <span class="fa-stack fa-lg">
                                <i class="iconfont icon-github"></i>
                            </span>
            </a>
        </li>
        

        

    </ul>
    
    <p>
        <span>/</span>
        
        <span><a href="https://github.com/Tooi6" target="_blank" rel="noopener">Tooi6</a></span>
        <span>/</span>
        
        <span><a href="#">Tooi-Blog</a></span>
        <span>/</span>
        
        <span><a href="#">It helps SEO</a></span>
        <span>/</span>
        
    </p>
    
    <p>
        <span id="busuanzi_container_site_pv">
            <span id="busuanzi_value_site_pv"></span>PV
        </span>
        <span id="busuanzi_container_site_uv">
            <span id="busuanzi_value_site_uv"></span>UV
        </span>
        Created By <a href="https://hexo.io/" target="_blank" rel="noopener">Hexo</a>  Theme <a href="https://github.com/aircloud/hexo-theme-aircloud" target="_blank" rel="noopener">AirCloud</a></p>
</footer>




</body>

<script>
    // We expose some of the variables needed by the front end
    window.hexo_search_path = "search.json"
    window.hexo_root = "/"
    window.isPost = true
</script>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="/js/index.js"></script>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>




</html>
